<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>
<ul>
  <li>li2</li>
</ul>
<script>
  var ul = document.querySelector('ul');

  var li1 = document.createElement('li');
  li1.innerHTML = 'li1';
  var li3 = document.createElement('li');
  li3.innerHTML = 'li3';
  ul.appendChild(li3);
  ul.insertBefore(li1, ul.children[0]);

</script>
</body>
</html>